#include <iostream>
#define MAXN 1000005
using namespace std;
int L, N, x, ants[MAXN];

void solve();


int main() {
    cin >> L >> N;
    for (int i = 0; i < N; i++) cin >> ants[i];
    solve();
    return 0;
}

void solve() {
    int mint = INT_MIN, maxt = INT_MIN;
    for (int i = 0; i < N; i++) {
        mint = max(mint, min(L - ants[i], ants[i]));
        maxt = max(maxt, max(L - ants[i], ants[i])); // 相当于存在一种摆放方式, 使得存在这种情况
    }
    cout << mint << " " << maxt << endl;
}